package cn.fl.ref.basicarchivesinfo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.ref.basicarchivesinfo.service.IBasicArchivesInfoService;
import cn.fl.ref.basicarchivesinfo.transform.BasicArchivesInfoVOTransform;
import cn.fl.ref.basicarchivesinfo.vo.BasicArchivesInfoVO;
import fl.ref.basicarchives.dto.BasicArchivesInfoDTO;
import fl.ref.basicarchives.service.IBasicArchivesInfoApiService;

@Service
public class BasicArchivesInfoServiceImpl implements IBasicArchivesInfoService {

	@Autowired
	private IBasicArchivesInfoApiService basicArchivesInfoApiService;
	
	/**
	 * 分页查询所有
	 * @param page
	 * @return
	 */
	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		if (null == page){
			page = new Pager();
		}
		return this.basicArchivesInfoApiService.searchListPage(page);
	}

	/**
	 * 新增
	 * @param vo
	 * @return
	 * @throws BaseException
	 */
	@Override
	public Long add(BasicArchivesInfoVO vo) throws BaseException {
		if (null == vo) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.basicArchivesInfoApiService.add(BasicArchivesInfoVOTransform.toDTO(vo));
	}

	/**
	 * 获取唯一对象
	 * 
	 * @param id 主键
	 * @return 对象VO
	 */
	@Override
	public BasicArchivesInfoVO selectById(Long id, String sysCd, String orgCd) throws BaseException {
		if (StringUtils.isEmpty(id)) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		BasicArchivesInfoDTO dto = this.basicArchivesInfoApiService.selectById(id,sysCd,orgCd);
		return BasicArchivesInfoVOTransform.toVO(dto);
	}

	/**
     * 修改
     * @param entity
     * @return
     */
	@Override
	public boolean modify(BasicArchivesInfoVO entity) throws BaseException {
		if (null == entity) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.basicArchivesInfoApiService.modify(BasicArchivesInfoVOTransform.toDTO(entity));
	}

	/**
     * 删除
     * @param id
     * @return
     */
	@Override
	public boolean removeById(Long id) throws BaseException {
		if (null == id) {
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.basicArchivesInfoApiService.removeById(id);
	}
	
	

}
